package com.lv.controller;

import com.lv.data.Result;
import com.lv.pojo.TbContent;
import com.lv.service.ContentService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("content")
public class ContentController {
    @DubboReference
    private ContentService cs;


    @RequestMapping("getContentByCategoryId")
    @ResponseBody
    public Result getContentByCategoryId(Integer categoryId, @RequestParam(defaultValue = "4")Integer pageSize){
        try {
            List<TbContent> contentList = cs.getContentByCategoryId(categoryId,pageSize);
            return Result.OK().setData(contentList);
        }catch (Exception e){
            return Result.ER();
        }
    }
}
